//导入工具类
import request from "@/utils/request";

//查询所有企业
export const getAllCompany = (pageNum,pageSize,keyword) =>{
    return request.get(`/company/page?pageNum=${pageNum}&pageSize=${pageSize}&keyWord=${keyword}`);
}

//根据id查询企业
export const getCompanyId = (companyId) =>{
    return request.get(`/companyId/${companyId}`);
}

//查询总页数
export const getAllPage = (keyword) =>{
    return request.get(`/company/count?keyWord=${keyword}`);
}

//删除企业名称
export const deleStore = (id) =>{
    let store = {
        id:id,
    }
    return request.get("/company/del",store);
}

//查询总行业类型
export const getAllIndustry = () =>{
    return request.get("/industrytype");
}

//查询总行业类型
export const getAllFinancing = () =>{
    return request.get("/financing");
}

//查询总题库
export const getAllTopic = () =>{
    return request.get("/topiclibrary");
}

//查询总题库
export const getAllCom = () =>{
    return request.get("/company");
}

//添加企业题库
export const addStoreTopic = (data) =>{
    let store = {
        topicLibraryId:data.topicLibraryId,
        companyId:data.companyId,
        tip: 0
    }
    return request.post("/companytopic",store);
}

//新增更新企业
export const updateStore = (data) =>{
    let store
    if(data.companyId == 0){
        store = {
            companyName: data.companyName,
            companyProfile: data.companyProfile,
            companyUrl: data.companyUrl,
            companyNum: data.companyNum,
            industryTypeId: data.industryTypeId,
            companyFullname: data.companyFullname,
            legalPerson: data.legalPerson,
            registeredCapita: data.registeredCapita,
            establishDate: data.establishDate,
            code: data.code,
            toWork: data.toWork,
            offWork: data.offWork,
            restType: data.restType,
            jobType: data.jobType,
            companySize: data.companyNum,
            financingId: data.financingId,
            tip: 0
        }
    }else{
        store = {
            companyId: data.companyId,
            companyName: data.companyName,
            companyProfile: data.companyProfile,
            companyUrl: data.companyUrl,
            companyNum: data.companyNum,
            industryTypeId: data.industryTypeId,
            companyFullname: data.companyFullname,
            legalPerson: data.legalPerson,
            registeredCapita: data.registeredCapita,
            establishDate: data.establishDate,
            code: data.code,
            toWork: data.toWork,
            offWork: data.offWork,
            restType: data.restType,
            jobType: data.jobType,
            companySize: data.companyNum,
            financingId: data.financingId,
            tip: 0
        }
    }
    
    return request.post("/company/addAndupdate",store);
}